// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DatabaseConnectString.cs" company="SmartPlan">
//   SmartPlan 2011
// </copyright>
// <summary>
//   The db connect string.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace DbDiff.Common.Model
{
    using Helper;

    /// <summary>
    /// The database connect string.
    /// </summary>
    public class DatabaseConnectString
    {
        /// <summary>
        /// The get connect string.
        /// </summary>
        /// <param name="server">
        /// The server.
        /// </param>
        /// <param name="database">
        /// The database.
        /// </param>
        /// <param name="userName">
        /// The user name.
        /// </param>
        /// <param name="password">
        /// The password.
        /// </param>
        /// <param name="authType">
        /// The auth type.
        /// </param>
        /// <returns>
        /// The sql connection string
        /// </returns>
        public static string GetConnectString(string server, string database, string userName, string password, AuthType authType)
        {
            string connectString = string.Empty;

            switch (authType)
            {
                case AuthType.Sql:
                    connectString = string.Format("PASSWORD={0};User ID={1};Initial Catalog={2};Data Source={3}", password, userName, database, server);
                    break;
                case AuthType.Win:
                    connectString = string.Format("Integrated Security=true;Data Source={0};Initial Catalog={1}", server, database);
                    break;
                case AuthType.Azure:
                    connectString = string.Format("Server=tcp:{0}.database.windows.net;Database={1};User ID={2}@{0};Password={3};Trusted_Connection=False;Encrypt=True;", server, database, userName, password);
                    break;
            }

            return connectString;
        }
    }
}